# -*- coding: utf-8 -*-
import datetime
import os


class BaseConfig:
    """通用配置"""
    # 基本配置
    ROOT_DIR = os.path.dirname(os.path.abspath(__file__))

    # JWT-extended
    JWT_SECRET_KEY = "secret_key"
    JWT_ACCESS_TOKEN_EXPIRES_SECONDS = 86400    # 24小时
    JWT_ACCESS_TOKEN_EXPIRES = datetime.timedelta(seconds=JWT_ACCESS_TOKEN_EXPIRES_SECONDS)
    JWT_TOKEN_LOCATION = ["headers", "cookies", "json", "query_string"]
    JWT_JSON_KEY = "token"
    JWT_REFRESH_JSON_KEY = "token"


class DevConfig(BaseConfig):
    """开发环境配置"""
    DEBUG = True

    # 数据库
    SQLALCHEMY_DATABASE_URI = "mysql+pymysql://root:123456@localhost:3306/e-commerce"
    SQLALCHEMY_TRACK_MODIFICATIONS = False


class TestConfig(BaseConfig):
    """测试环境配置"""
    DEBUG = True

    # 数据库
    SQLALCHEMY_DATABASE_URI = "mysql+pymysql://root:123456@localhost:3306/e-commerce"
    SQLALCHEMY_TRACK_MODIFICATIONS = False


class ProConfig(BaseConfig):
    """生产环境配置"""
    DEBUG = False

    # 数据库
    SQLALCHEMY_DATABASE_URI = "mysql+pymysql://root:123456@localhost:3306/e-commerce"
    SQLALCHEMY_TRACK_MODIFICATIONS = False


ConfigMapping = {
    'dev': DevConfig(),
    'test': TestConfig(),
    'pro': ProConfig()
}